import Types from '@/components/CustomPage/workflow/common/types'
import {
  Slider,
  Radio,
  Color,
  Input,
  Select,
  Link, Switch, Mapping
} from '@/components/CustomPage/fields/widget'
import { DataOption } from './dataops'
import { DataOption4Text } from './dataops4Text'
import NewsClassifyComp from '../widget/news/newsClassifyComp'
import newsListStyleOneComp from '../widget/news/newsListStyleOneComp'
import newsListStyleFourComp from '../widget/news/newsListStyleFourComp'
import newsListStyleThreeComp from '../widget/news/newsListStyleThreeComp'
import indexNewsClassifyComp from '../widget/news/indexNewsClassifyComp'
import { BasicOption } from './basicops'
import '@/styles/variables.scss'
import { sourceOption, sourceNoNumOption } from '@/components/CustomPage/apps/map/source'
import { moreLinkOps } from '@/components/CustomPage/apps/map/moreLinkops'
import { imgOption } from '@/components/CustomPage/apps/map/imgops'
import { DataOption4Img } from '@/components/CustomPage/apps/map/dataops4img'
import { cellTitleOps } from '@/components/CustomPage/apps/map/cellTitleops'
import { radiusSizeOps } from '@/components/CustomPage/apps/map/radiusSizeOps'
import { bgImgColor } from './bgImgColor'
export default {

  /**
     * 新闻分类组件
     */
  newsClassifyComp() {
    return {
      target: NewsClassifyComp,
      parameter: {
        relate: true,
        mold: 'field',
        label: '新闻分类',
        value: ''
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            {
              type: Color,
              option: {
                label: '背景颜色',
                name: 'bgcolor',
                value: '#fff',
                showalpha: true
              }
            },
            {
              type: Color,
              option: {
                label: '文字颜色',
                name: 'textcolor',
                value: '#333',
                showalpha: true
              }
            },
            {
              type: Radio,
              option: {
                label: '是否固定定位',
                name: 'isFixed',
                list: [
                  { name: '是', value: '1' },
                  { name: '否', value: '2' }
                ],
                value: '2'
              }
            },
            {
              type: Slider,
              option: {
                label: '顶部距离',
                name: 'fixedToTop',
                value: 0,
                step: 1
              }
            },
            {
              type: Mapping,
              option: {
                label: '',
                name: 'mapping',
                list: [
                  { name: '分类名称', code: 'classifyName', value: '' }
                ]
              }
            }
          ]
        },
        ...DataOption4Img('dataList', [], 'text')
      ],
      valueType: Types.VALUETYPES.CATEGORYCHANGE
    }
  },

  /**
     * 首页新闻分类组件
     */
  indexNewsClassifyComp() {
    return {
      target: indexNewsClassifyComp,
      parameter: {
        relate: true,
        mold: 'field',
        label: '首页新闻分类',
        value: ''
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            { type: Slider, option: { label: '左右间距', name: 'paddingLeftRight', value: 0, max: 50, step: 1 }},
            { type: Color, option: { label: '背景颜色', name: 'bgcolor', value: '', showalpha: true }},
            {
              type: Switch,
              option: {
                label: '自定义指示线颜色',
                name: 'isThemeColor',
                value: false,
                activetext: '是',
                inactivetext: '否',
                override: function(ths, e) {
                  ths.$nextTick(() => {
                    for (let i = 0; i < ths.$parent.$parent.$children.length; i++) {
                      if (ths.$parent.$parent.$children[i].option.name === 'currentcolor') {
                        ths.$parent.$parent.$children[i].visible = e
                      }
                    }
                  })
                }
              }
            },
            {
              type: Color,
              option: {
                label: '指示线颜色',
                name: 'currentcolor',
                value: sessionStorage.getItem('THEME_COLOR') || '#e44d42',
                showalpha: true
              }
            }
          ]
        },
        ...DataOption()
      ],
      valueType: Types.VALUETYPES.CATEGORYCHANGE
    }
  },
  /**
     * 新闻列表组件
     */
  newsListStyleOneComp() {
    return {
      target: newsListStyleOneComp,
      parameter: {
        relate: false,
        mold: 'field',
        label: '新闻列表',
        value: []
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            ...sourceNoNumOption(),
            {
              type: Slider,
              option: {
                label: '左右边距',
                name: 'spacing',
                value: 0,
                max: 100,
                step: 1
              }
            },
            {
              type: Select,
              option: {
                label: '展示样式',
                name: 'resource',
                list: [
                  { name: '新闻样式', value: 'xw' },
                  { name: '资料样式', value: 'zl' }
                ],
                value: 'xw'
              }
            },
            {
              type: Switch,
              option: {
                label: '是否展示标题名称',
                name: 'isShowModuleName',
                value: true,
                activetext: '是',
                inactivetext: '否',
                override: function(ths, e) {
                  ths.$nextTick(() => {
                    for (let i = 0; i < ths.$parent.$parent.$children.length; i++) {
                      const name = ths.$parent.$parent.$children[i].option.name
                      if (name === 'moduleName' || name === 'backgroundColor' || name === 'radiusSize') {
                        ths.$parent.$parent.$children[i].visible = e
                      }
                    }
                  })
                }
              }
            },
            {
              type: Input,
              option: {
                label: '标题名称',
                name: 'moduleName',
                value: '标题名称'
              }
            },
            { type: Color,
              option: {
                label: '标题背景颜色',
                name: 'backgroundColor',
                value: 'rgba(255, 255, 255, 1)',
                showalpha: true
              }
            },
            { type: Slider, option: { label: '圆角大小', name: 'radiusSize', value: 20, max: 45, step: 1 }},
            ...imgOption(),
            {
              type: Switch,
              option: {
                label: '是否立即初始化',
                name: 'isInit',
                value: true,
                activetext: '是',
                inactivetext: '否'
              }
            },
            { type: Link, option: { label: '详情地址', name: 'link' }},
            {
              type: Mapping,
              option: {
                label: '',
                name: 'mapping',
                list: [
                  { name: '封面', code: 'coverImgId', value: '' },
                  { name: 'oss封面', code: 'coverImgIdUrl', value: '' },
                  { name: '标题', code: 'mainTitle', value: '' },
                  { name: '时间', code: 'publishTime', value: '' }
                ]
              }
            }
          ]
        },
        ...DataOption()
      ]
    }
  },

  /**
   * 新闻列表组件4
   */
  newsListStyleFourComp() {
    return {
      target: newsListStyleFourComp,
      parameter: {
        relate: true,
        mold: 'field',
        label: '新闻列表样式4',
        value: []
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            ...sourceNoNumOption(),
            {
              type: Slider,
              option: {
                label: '左右边距样式4',
                name: 'spacing',
                value: 0,
                max: 100,
                step: 1
              }
            },
            {
              type: Select,
              option: {
                label: '展示样式',
                name: 'resource',
                list: [
                  { name: '新闻样式', value: 'xw' },
                  { name: '资料样式', value: 'zl' }
                ],
                value: 'xw'
              }
            },
            {
              type: Switch,
              option: {
                label: '是否展示标题名称',
                name: 'isShowModuleName',
                value: true,
                activetext: '是',
                inactivetext: '否',
                override: function(ths, e) {
                  ths.$nextTick(() => {
                    for (let i = 0; i < ths.$parent.$parent.$children.length; i++) {
                      const name = ths.$parent.$parent.$children[i].option.name
                      if (name === 'moduleName' || name === 'backgroundColor' || name === 'radiusSize') {
                        ths.$parent.$parent.$children[i].visible = e
                      }
                    }
                  })
                }
              }
            },
            {
              type: Input,
              option: {
                label: '标题名称',
                name: 'moduleName',
                value: '标题名称'
              }
            },
            { type: Color,
              option: {
                label: '标题背景颜色',
                name: 'backgroundColor',
                value: 'rgba(255, 255, 255, 1)',
                showalpha: true
              }
            },
            { type: Slider, option: { label: '圆角大小', name: 'radiusSize', value: 20, max: 45, step: 1 }},
            ...imgOption(),
            {
              type: Switch,
              option: {
                label: '是否立即初始化',
                name: 'isInit',
                value: true,
                activetext: '是',
                inactivetext: '否'
              }
            },
            { type: Link, option: { label: '详情地址', name: 'link' }},
            {
              type: Mapping,
              option: {
                label: '',
                name: 'mapping',
                list: [
                  { name: '封面', code: 'coverImgId', value: '' },
                  { name: 'oss封面', code: 'coverImgIdUrl', value: '' },
                  { name: '标题', code: 'mainTitle', value: '' },
                  { name: '时间', code: 'publishTime', value: '' }
                ]
              }
            }
          ]
        },
        ...DataOption()
      ],
      valueType: Types.VALUETYPES.CATEGORYCHANGE
    }
  },
  /**
     * 新闻列表右上角查看更多
     */
  newsListStyleThreeComp() {
    return {
      target: newsListStyleThreeComp,
      parameter: {
        relate: false,
        mold: 'field',
        label: '新闻列表（固定数量）2',
        value: []
      },
      option: [
        {
          title: '基础配置',
          fields: [
            ...BasicOption(),
            ...sourceOption(),
            ...cellTitleOps(),
            ...bgImgColor(),
            ...radiusSizeOps(),
            // {
            //   type: Switch,
            //   option: {
            //     label: '是否展示标题名称',
            //     name: 'isShowModuleName',
            //     value: true,
            //     activetext: '是',
            //     inactivetext: '否',
            //     override: function(ths, e) {
            //       ths.$nextTick(() => {
            //         for (let i = 0; i < ths.$parent.$parent.$children.length; i++) {
            //           const name = ths.$parent.$parent.$children[i].option.name
            //           if (name === 'moduleName' || name === 'backgroundColor' || name === 'radiusSize') {
            //             ths.$parent.$parent.$children[i].visible = e
            //           }
            //         }
            //       })
            //     }
            //   }
            // },
            // {
            //   type: Input,
            //   option: {
            //     label: '标题名称',
            //     name: 'moduleName',
            //     value: '标题名称'
            //   }
            // },
            // { type: Color,
            //   option: {
            //     label: '标题背景颜色',
            //     name: 'backgroundColor',
            //     value: 'rgba(255, 255, 255, 1)',
            //     showalpha: true
            //   }
            // },
            // { type: Slider, option: { label: '圆角大小', name: 'radiusSize', value: 12, max: 45, step: 1 }},
            // {
            //   type: Slider,
            //   option: {
            //     label: '上边距',
            //     name: 'top',
            //     value: 0,
            //     max: 100,
            //     step: 1
            //   }
            // },
            {
              type: Slider,
              option: {
                label: '左右边距',
                name: 'spacing',
                value: 0,
                max: 100,
                step: 1
              }
            },
            {
              type: Select,
              option: {
                label: '展示样式',
                name: 'resource',
                list: [
                  { name: '新闻样式', value: 'xw' },
                  { name: '资料样式', value: 'zl' }
                ],
                value: 'xw'
              }
            },
            ...imgOption(),
            ...moreLinkOps(),
            { type: Link, option: { label: '详情地址', name: 'link' }},
            {
              type: Mapping,
              option: {
                label: '',
                name: 'mapping',
                list: [
                  { name: '封面', code: 'coverImgId', value: '' },
                  { name: 'oss封面', code: 'coverImgIdUrl', value: '' },
                  { name: '标题', code: 'mainTitle', value: '' },
                  { name: '时间', code: 'publishTime', value: '' }
                ]
              }
            }
          ]
        },
        ...DataOption()
      ]
    }
  }

}
